package com.wmobile.ui;

import com.wellsoft.mobileoa.utils.SystemConfig;

import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.widget.TextView;

public class AutoResizeTextView extends TextView {
	Context context;
	int fixedHeight;

	public void setFixedHeight(int fixedHeight) {
		this.fixedHeight = fixedHeight;
	}

	public AutoResizeTextView(Context context) {
		super(context);
		this.context = context;
	}

	public AutoResizeTextView(Context context, AttributeSet attrs) {
		super(context, attrs);
		this.context = context;
		String heightStr = attrs.getAttributeValue(
				"http://schemas.android.com/apk/res/android", "tag");
		if (SystemConfig.isInt(heightStr)) {
			this.fixedHeight = Integer.parseInt(heightStr);
		}
	}

	public AutoResizeTextView(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
		this.context = context;
		String heightStr = attrs.getAttributeValue(
				"http://schemas.android.com/apk/res/android", "tag");
		if (SystemConfig.isInt(heightStr)) {
			this.fixedHeight = Integer.parseInt(heightStr);
		}
	}

//	@Override
//	protected void onSizeChanged(int w, int h, int oldw, int oldh) {
//		// try {
//		// Thread.currentThread().sleep(500);
//		// } catch (InterruptedException e) {
//		// // TODO Auto-generated catch block
//		// e.printStackTrace();
//		// }
//		super.onSizeChanged(w, h, oldw, oldh);
//		Log.v("fixedheight", w + " " + h + " " + oldw + " " + oldh);
//		if (h < SystemConfig.dip2px(context, fixedHeight)) {
//			this.setHeight(SystemConfig.dip2px(context, fixedHeight));
//			Log.v("fixedheight", "" + SystemConfig.dip2px(context, fixedHeight)
//					+ " " + h);
//		}
//	}
}
